package com.bjpowernode.servlets;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class OtherServlet implements Servlet {
	private ServletConfig config;
	@Override
	public void init(ServletConfig config) throws ServletException {
		this.config = config;
	}

	@Override
	public ServletConfig getServletConfig() {
		return config;
	}

	@Override
	public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
		// 获取ServletContext对象
		ServletContext sc = config.getServletContext();
		
		// 获取域属性的值
		String mobile = (String) sc.getAttribute("mobile");
		System.out.println("mobile = " + mobile);
		
		// 重置域属性的值
		sc.setAttribute("mobile", "7654321");
		
		// 删除域属性
		sc.removeAttribute("email");
	}

	@Override
	public String getServletInfo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

}
